package org.eclipse.jdt.internal.ui.callhierarchy;

import java.util.Map;

import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;

public abstract class InterceptorFieldRefactor extends AbstractFieldRefactor {


	public void refactor(IField field) throws JavaModelException {
		IType type = field.getDeclaringType();
		
		if (type != null) {
			RefactorClass refactorClass = getRefactorClassBuilder().buildClass(type);
			
			if (refactorClass != null) {
				preRefactor(field, refactorClass);
				Map<String, String> model = buildModel(field);
				interceptModel(model, field);
				refactor(field, refactorClass, model);
			}
		}
	}
	
	protected abstract void preRefactor(IField field, RefactorClass refactorClass) throws JavaModelException;
	
	protected abstract void refactor(IField field, RefactorClass refactorClass, Map<String, String> model) throws JavaModelException;

	protected abstract Map<String, String> buildModel(IField field) throws JavaModelException;
	
	protected abstract void interceptModel(Map<String, String> model, IField field) throws JavaModelException;

}
